package de.gwtprime.client.activities;



import java.util.logging.Logger;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

import de.gwtprime.client.ClientFactory;
import de.gwtprime.client.places.ArticleOverviewPlace;
import de.gwtprime.client.places.ArticlePlace;
import de.gwtprime.client.places.ArticleSectionPlace;
import de.gwtprime.client.places.ImpressumPlace;
import de.gwtprime.client.places.QuestionPlace;
import de.gwtprime.client.places.UserAccountPlace;
import de.gwtprime.client.places.WelcomePlace;

public class AppActivityMapper implements ActivityMapper {

	/**
	 * Logger
	 */
	private static Logger logger = Logger.getLogger(AppActivityMapper.class.getName());
	
	private ClientFactory clientFactory;
	
	public AppActivityMapper(ClientFactory clientFactory){
		super();
		this.clientFactory = clientFactory;
		
	}
	
	@Override
	public Activity getActivity(Place place) {
		
		if(place instanceof ArticlePlace){
			return new ArticleActivity((ArticlePlace)place, clientFactory);
		}else if(place instanceof ImpressumPlace)
			return new ImpressumActivity((ImpressumPlace)place, clientFactory);
		else if(place instanceof WelcomePlace)
			return new WelcomeActivity((WelcomePlace)place, clientFactory);
		else if(place instanceof UserAccountPlace)
			return new UserAccountActivity((UserAccountPlace)place, clientFactory);
		else if(place instanceof QuestionPlace)
			return new QuestionActivity((QuestionPlace)place, clientFactory);
		else if(place instanceof ArticleOverviewPlace)
			return new ArticleAcitvityOverview((ArticleOverviewPlace)place, clientFactory);
		else if(place instanceof ArticleSectionPlace)
			return new ArticleSectionActivity((ArticleSectionPlace)place, clientFactory);
		
		
		logger.warning("AppActivityMapper: PLACE NOT FOUND: "+place);
		return null;
	}

}
